class Node {
    constructor (data, firstChild, brother) {
        this.data = data
        this.firstChild = firstChild || null
        this.brother = brother || null
    }
}

var g = new Node('G', null, null)
var f = new Node('F', null, g)
var e = new Node('E', null, f)
var d = new Node('D', null, null)
var c = new Node('C', e, d)
var b = new Node('B', null, c)
var a = new Node('A', b, null)




var tree = a

function preOrder(node) {
    if (!node) {
        return
    }
    preOrder(node.firstChild)
    preOrder(node.brother)
    console.log(node.data)
}

preOrder(tree)